package com.example.controller;

import com.example.common.result.Result;
import com.example.entity.dto.TicketDto;
import com.example.entity.dto.WorkOrderProcessDto;
import com.example.entity.vo.gd.CmsMqVoEnglish;
import com.example.entity.vo.gd.CraftVo;
import com.example.entity.vo.gd.TicketVo;
import com.example.entity.vo.gd.WorkOrderProcessVo;
import com.example.entity.yifei.Copma;
import com.example.service.TicketsService;
import com.mgkj.dao.share.vo.WorkCenterVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@CrossOrigin // 解决跨域
@RestController
@RequestMapping("/api/Tickets")
@Api(tags = "关于生产工单信息前端控制器")
public class TicketsController {

    @Resource
    private TicketsService ticketsService;

    @ApiOperation("查询工单单别信息")
    @GetMapping("/queryTicketDb")
    public Result<List<CmsMqVoEnglish>> queryTicketDb(){
        return this.ticketsService.queryTicketDb("51");
    }

    @ApiOperation("查询工作中心")
    @GetMapping("/queryWorkCenter")
    public Result<List<WorkCenterVo>> queryWorkCenterVo(){
        return this.ticketsService.queryWorkCenterVo();
    }

    @ApiOperation("分页查询工单信息")
    @PostMapping("/queryTicketIpAge/{current}/{size}")
    public Result<Map<String,TicketVo>> queryTicketIpAge(@PathVariable Integer current, @PathVariable Integer size, @RequestBody TicketDto ticketDto){
        return this.ticketsService.queryTicketIpAge(current,size,ticketDto);
    }

    @ApiOperation("查询工单工艺")
    @GetMapping("/queryWorkOrderProcess/{ta001}/{ta002}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ta001",value = "单别",dataType = "String",paramType = "path",required = true,dataTypeClass = String.class),
            @ApiImplicitParam(name = "ta002",value = "单号",dataType = "String",paramType = "path",required = true,dataTypeClass = String.class)
    })
    public Result<List<WorkOrderProcessVo>> queryWorkOrderProcess(@PathVariable String ta001, @PathVariable String ta002){
        return this.ticketsService.queryWorkOrderProcess(ta001,ta002);
    }

    @ApiOperation("查询工艺")
    @GetMapping("/queryCraft/{division}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "division",value = "传all为查全部的工艺，输入工作中心编号则查询工作中心的编号",dataType = "String",paramType = "path",required = true,dataTypeClass = String.class)
    })
    public Result<List<CraftVo>> queryCraft(@PathVariable String division){
        return this.ticketsService.queryCraft(division);
    }

    @ApiOperation("工单工艺(新增或修改)")
    @PostMapping("/insertOrUpdateWorkOrderProcess")
    public Result<?> insertOrUpdateWorkOrderProcess(@RequestBody List<WorkOrderProcessDto> workOrderProcessDtoList){
        return this.ticketsService.insertOrUpdateWorkOrderProcess(workOrderProcessDtoList);
    }

    @ApiOperation("删除工单工艺")
    @GetMapping("/deleteCraft/{ta001}/{ta002}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ta001",value = "单别",dataType = "String",paramType = "path",required = true,dataTypeClass = String.class),
            @ApiImplicitParam(name = "ta002",value = "单号",dataType = "String",paramType = "path",required = true,dataTypeClass = String.class)
    })
    public Result<?> deleteCraft(@PathVariable String ta001,@PathVariable String ta002){
        return this.ticketsService.deleteCraft(ta001,ta002);
    }

    @ApiOperation("客户信息")
    @GetMapping("listCustomer")
    public Result<List<Copma>> listCustomer(){
        return ticketsService.listCustomer();
    }
}
